﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicClass;
using S.Services.SheepMale.Read.Api.Application.ReadCommand.ReadSheepMaleCommand;

namespace S.Services.SheepMale.Read.Api.Controllers
{
    /// <summary>
    /// 采购销售读取管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReadPurchaseController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReadPurchaseController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 个体采购显示
        /// </summary>
        /// <param name="request"></param>  
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandlePurchaseShow([FromQuery] PurchaseShowCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request));
        }
        /// <summary>
        /// 获取个体采购数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleGetPurchase([FromQuery]PruchaseGetCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request));
        }
        /// <summary>
        /// 获取羊只类型下拉框
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleSheepType([FromQuery]GetSheepTypeCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request)); 
        }
        /// <summary>
        /// 获取核算单元下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleAccounting([FromQuery]GetAccountingCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request));
        }
        /// <summary>
        /// 获取仓库下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleStash([FromQuery] GetStashCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request));
        }
        /// <summary>
        /// 获取摘要下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleDigest([FromQuery]GetDigestCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request));
        }
    }
}
